package org.gap.service;

import java.util.Calendar;
import java.util.List;
import java.util.Set;

import org.gap.domain.AdressesTiers;
import org.gap.domain.Utilisateurs;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/GAP_v2-security-context.xml",
		"file:./resources/GAP_v2-service-context.xml",
		"file:./resources/GAP_v2-dao-context.xml",
		"file:./resources/GAP_v2-web-context.xml" })
@Transactional
public class AdressesTiersServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected AdressesTiersService service;

	/**
	 * Instantiates a new AdressesTiersServiceTest.
	 *
	 */
	public AdressesTiersServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void deleteAdressesTiersUtilisateursByAdtUserCreation() {
		// TODO: JUnit - Populate test inputs for operation: deleteAdressesTiersUtilisateursByAdtUserCreation 
		Integer adressestiers_adtAdresse = 0;
		Integer adressestiers_adtTiers = 0;
		String adressestiers_adtTypeAdresse = null;
		String adressestiers_adtEtatAffectation = null;
		Calendar adressestiers_adtFinAffectation = null;
		String related_utilisateursbyadtusercreation_usrUser = null;
		AdressesTiers response = null;
		response = service.deleteAdressesTiersUtilisateursByAdtUserCreation(adressestiers_adtAdresse, adressestiers_adtTiers, adressestiers_adtTypeAdresse, adressestiers_adtEtatAffectation, adressestiers_adtFinAffectation, related_utilisateursbyadtusercreation_usrUser);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteAdressesTiersUtilisateursByAdtUserCreation
	}

	/**
	 * Operation Unit Test
	 * Save an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void saveAdressesTiersUtilisateursByAdtUserModification() {
		// TODO: JUnit - Populate test inputs for operation: saveAdressesTiersUtilisateursByAdtUserModification 
		Integer adtAdresse = 0;
		Integer adtTiers = 0;
		String adtTypeAdresse = null;
		String adtEtatAffectation = null;
		Calendar adtFinAffectation = null;
		Utilisateurs related_utilisateursbyadtusermodification = new org.gap.domain.Utilisateurs();
		AdressesTiers response = null;
		response = service.saveAdressesTiersUtilisateursByAdtUserModification(adtAdresse, adtTiers, adtTypeAdresse, adtEtatAffectation, adtFinAffectation, related_utilisateursbyadtusermodification);
		// TODO: JUnit - Add assertions to test outputs of operation: saveAdressesTiersUtilisateursByAdtUserModification
	}

	/**
	 * Operation Unit Test
	 * Delete an existing AdressesTiers entity
	 * 
	 */
	@Test
	public void deleteAdressesTiers() {
		// TODO: JUnit - Populate test inputs for operation: deleteAdressesTiers 
		AdressesTiers adressestiers = new org.gap.domain.AdressesTiers();
		service.deleteAdressesTiers(adressestiers);
	}

	/**
	 * Operation Unit Test
	 * Return all AdressesTiers entity
	 * 
	 */
	@Test
	public void findAllAdressesTierss() {
		// TODO: JUnit - Populate test inputs for operation: findAllAdressesTierss 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<AdressesTiers> response = null;
		response = service.findAllAdressesTierss(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllAdressesTierss
	}

	/**
	 * Operation Unit Test
	 * Save an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void saveAdressesTiersUtilisateursByAdtUserCreation() {
		// TODO: JUnit - Populate test inputs for operation: saveAdressesTiersUtilisateursByAdtUserCreation 
		Integer adtAdresse_1 = 0;
		Integer adtTiers_1 = 0;
		String adtTypeAdresse_1 = null;
		String adtEtatAffectation_1 = null;
		Calendar adtFinAffectation_1 = null;
		Utilisateurs related_utilisateursbyadtusercreation = new org.gap.domain.Utilisateurs();
		AdressesTiers response = null;
		response = service.saveAdressesTiersUtilisateursByAdtUserCreation(adtAdresse_1, adtTiers_1, adtTypeAdresse_1, adtEtatAffectation_1, adtFinAffectation_1, related_utilisateursbyadtusercreation);
		// TODO: JUnit - Add assertions to test outputs of operation: saveAdressesTiersUtilisateursByAdtUserCreation
	}

	/**
	 * Operation Unit Test
	 * Load an existing AdressesTiers entity
	 * 
	 */
	@Test
	public void loadAdressesTierss() {
		Set<AdressesTiers> response = null;
		response = service.loadAdressesTierss();
		// TODO: JUnit - Add assertions to test outputs of operation: loadAdressesTierss
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findAdressesTiersByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findAdressesTiersByPrimaryKey 
		Integer adtAdresse_2 = 0;
		Integer adtTiers_2 = 0;
		String adtTypeAdresse_2 = null;
		String adtEtatAffectation_2 = null;
		Calendar adtFinAffectation_2 = null;
		AdressesTiers response = null;
		response = service.findAdressesTiersByPrimaryKey(adtAdresse_2, adtTiers_2, adtTypeAdresse_2, adtEtatAffectation_2, adtFinAffectation_2);
		// TODO: JUnit - Add assertions to test outputs of operation: findAdressesTiersByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void deleteAdressesTiersUtilisateursByAdtUserModification() {
		// TODO: JUnit - Populate test inputs for operation: deleteAdressesTiersUtilisateursByAdtUserModification 
		Integer adressestiers_adtAdresse_1 = 0;
		Integer adressestiers_adtTiers_1 = 0;
		String adressestiers_adtTypeAdresse_1 = null;
		String adressestiers_adtEtatAffectation_1 = null;
		Calendar adressestiers_adtFinAffectation_1 = null;
		String related_utilisateursbyadtusermodification_usrUser = null;
		AdressesTiers response = null;
		response = service.deleteAdressesTiersUtilisateursByAdtUserModification(adressestiers_adtAdresse_1, adressestiers_adtTiers_1, adressestiers_adtTypeAdresse_1, adressestiers_adtEtatAffectation_1, adressestiers_adtFinAffectation_1, related_utilisateursbyadtusermodification_usrUser);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteAdressesTiersUtilisateursByAdtUserModification
	}

	/**
	 * Operation Unit Test
	 * Save an existing AdressesTiers entity
	 * 
	 */
	@Test
	public void saveAdressesTiers() {
		// TODO: JUnit - Populate test inputs for operation: saveAdressesTiers 
		AdressesTiers adressestiers_1 = new org.gap.domain.AdressesTiers();
		service.saveAdressesTiers(adressestiers_1);
	}

	/**
	 * Operation Unit Test
	 * Return a count of all AdressesTiers entity
	 * 
	 */
	@Test
	public void countAdressesTierss() {
		Integer response = null;
		response = service.countAdressesTierss();
		// TODO: JUnit - Add assertions to test outputs of operation: countAdressesTierss
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
